package pers.zhuli.weblog.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import pers.zhuli.weblog.entity.Article;

import java.util.List;
import java.util.Map;

public interface ArticleDAO extends JpaRepository<Article, Integer> {
    @Query(value = "SELECT id,title from article order by create_datetime desc limit ?1", nativeQuery = true)
    List<Map<Integer, String>> _getNewTop(int num);

    @Query(nativeQuery = true, value = "select id,title from article order by read_count limit ?1")
    List<Map<Integer, String>> _getHotTop(int num);

    Article findById(int id);
}
